//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
import MebcouponggroupDetails from "../../views/mall/MebcoupongroupDetails.vue"
let extension = {
  components: {//动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
    gridBody: MebcouponggroupDetails,
    gridFooter: '',
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  buttons: {
    view: [
      {
        name: "新建",
        icon: 'md-add',
        value: 'XJ',
        class: '',
        type: 'error',
        index: 1,
        onClick: function () {
          this.$refs.gridBody.model1 = true;
          this.$refs.gridBody.GETHISLIST()
          this.$refs.gridBody.GetVueDictionary()
          this.$nextTick(() => {
            this.$refs.gridBody.$refs.myform1.reset()
            this.$refs.gridBody.$refs.editTable1.reset()
          })
        }
      },
      // {
      //   name: "编辑",
      //   icon: 'md-create',
      //   value: 'BJ',
      //   class: '',
      //   type: 'success',
      //   index: 2,
      //   onClick: function () {
      //     this.$refs.gridBody.model1 = true;
      //     this.$refs.gridBody.GETHISLIST()
      //     this.$refs.gridBody.GetVueDictionary()
      //   }
      // }
    ], box: [], detail: []
  },//扩展的按钮
  methods: {//事件扩展
    getFormOption (field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        })
      })
      return option;
    },
    onInit () {
      this.columns.push({
        title: '操作',
        fixed: 'right',
        width: 120,
        render: (h, { row, column, index }) => {
          return [h(
            'a', {
            on: {
              click: () => {
               this.$refs.gridBody.model3 = true;
               console.log(row.coupon_makeid,"row")
               this.$refs.gridBody.formFields3.coupon_makeid = row.coupon_makeid
         
              }
            }
          }, "发券包"),
            // h(
            //   'a', {
            //   on: {
            //     click: () => {
            //       this.$refs.gridFooter.model2 = true
            //       let param = {
            //         order: "desc",
            //         page: 1,
            //         rows: 30,
            //         sort: "id",
            //         wheres: `[{\"name\":\"coupon_code\",\"value\":\"${row.code}\",\"displayType\":\"like\"}]`,
            //       }
            //       this.http.post('/api/MebcouponMake/getPageData', param).then(res => {
            //         this.$refs.gridFooter.tableData = res.rows
            //       })
            //     }
            //   }
            // }, "  查看券"),
          ]
        }
      })
      this.$store.getters.data().viewPageTest = this;
      let parmas = {
        order: "desc",
        page: 1,
        rows: 10000,
        sort: "id",
        wheres: "[]"
      }
      this.http.post('/api/MebCoupon/getPageData', parmas).then(res => {
        this.columns.forEach(i => {
          if (i.field == 'coupon_code') {
            res.rows.forEach(j => {
              let o = {
                key: j.code,
                value: j.name
              }
              i.bind.data.push(o)
            })
          }
        })
      })
    },
    rowClick ({ row, column, event }) { //查询界面table点击行选中当前行
      this.$refs.table.$refs.table.toggleRowSelection(row);
      return true;
    },
    searchBefore (param) {
      let wheres = [{
        'name': 'coupon_type',
        'value': '1',
        'displayType': 'text'//设置为模糊查询,其他不需要设置
      }]

      param.wheres.push(...wheres);
      return true
    }
  },
};

export default extension;